home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 3 / ct-rom iiib.zip / ct-rom iiib / WINDOWS / DIVERSEN / WINE02BX / BLACKBOX.ELC < prev    next >
Text File  |  1993-03-28  |  9KB  |  146 lines

  1. ;;; compiled by jwz@thalidomide on Thu Jul  2 16:31:51 1992
  2. ;;; from file /u/jwz/emacs19/lisp/packages/blackbox.el
  3. ;;; emacs version 19.2.1 Lucid.
  4. ;;; bytecomp version 2.07; 17-jun-92.
  5. ;;; optimization is on.
  6. ;;; this file uses opcodes which do not exist in Emacs18.
  7.  
  8. (if (and (boundp 'emacs-version)
  9.      (or (and (boundp 'epoch::version) epoch::version)
  10.          (string-lessp emacs-version "19")))
  11.     (error "This file was compiled for Emacs19."))
  12.  
  13. (defvar blackbox-mode-map nil "\
  14. ")
  15. (byte-code "¼╕┴ ┬├\"ê─┼╞#ê─╟╚#ê─╔╩#ê─╦╠#ê─═╬#ê─╧╨#ê─╤╥#ê─╙╘#ê╒╓╫╪#ç" [blackbox-mode-map make-keymap suppress-keymap t define-key "" bb-right "" bb-left "" bb-up "" bb-down "" bb-eol "" bb-bol " " bb-romp "" bb-done put blackbox-mode mode-class special] 4)
  16. (fset 'blackbox-mode #[nil "└ ê┴\n!ê├┼╟ëç" [kill-all-local-variables use-local-map blackbox-mode-map t truncate-lines blackbox-mode major-mode "Blackbox" mode-name] 2 "\
  17. Major mode for playing blackbox.  To learn how to play blackbox,
  18. see the documentation for function  blackbox.
  19.  
  20. The usual mnemonic keys move the cursor around the box.
  21. C-a and C-e move to the beginning and end of line, respectively.
  22. Using other methods of moving point loses.
  23.  
  24. SPC -- send in a ray from point, or toggle a ball at point
  25. RET -- end game and get score
  26.  
  27. Precisely,\\{blackbox-mode-map}" nil])
  28. (fset 'blackbox #[(num) "└┴!ê┬ ê├┼p!ê╞«ü╚!    ╩ ╠╠╧╧╥ ê╙B!ç" [switch-to-buffer "*Blackbox*" blackbox-mode t buffer-read-only buffer-disable-undo bb-init-board num 4 bb-board nil bb-balls-placed -1 bb-x bb-y 0 bb-score bb-detour-count bb-insert-board bb-goto] 3 "\
  29. Play blackbox.  Arg is number of balls; default is 4.
  30.  
  31. What is blackbox?
  32.  
  33. Blackbox is a game of hide and seek played on an 8 by 8 grid (the
  34. Blackbox).  Your opponent (Emacs, in this case) has hidden several
  35. balls (usually 4) within this box.  By shooting rays into the box and
  36. observing where they emerge it is possible to deduce the positions of
  37. the hidden balls.  The fewer rays you use to find the balls, the lower
  38. your score.
  39.  
  40. Overview of play:
  41.  
  42. To play blackbox, call the function blackbox.  An optional prefix
  43. argument specifies the number of balls to be hidden in the box; the
  44. default is four.
  45.  
  46. The cursor can be moved around the box with the standard cursor
  47. movement keys.  Using any other form of cursor movement is guaranteed
  48. not to work correctly.
  49.  
  50. To shoot a ray, move the cursor to the edge of the box and press SPC.
  51. The result will be determined and the playfield updated.
  52.  
  53. You may place or remove balls in the box by moving the cursor into the
  54. box and pressing SPC.
  55.  
  56. When you think the configuration of balls you have placed is correct,
  57. press RET.  You will be informed whether you are correct or not, and
  58. be given your score.  Your score is the number of letters and numbers
  59. around the outside of the box plus five for each incorrectly placed
  60. ball.  If you placed any balls incorrectly, they will be indicated
  61. with 'x', and their actual positions indicated with 'o'.
  62.  
  63. Details:
  64.  
  65. There are three possible outcomes for each ray you send into the box:
  66.  
  67.     Detour: the ray is deflected and emerges somewhere other than
  68.         where you sent it in.  On the playfield, detours are
  69.         denoted by matching pairs of numbers -- one where the
  70.         ray went in, and the other where it came out.
  71.  
  72.     Reflection: the ray is reflected and emerges in the same place
  73.         it was sent in.  On the playfield, reflections are
  74.         denoted by the letter 'R'.
  75.  
  76.     Hit:    the ray strikes a ball directly and is absorbed.  It does
  77.         not emerge from the box.  On the playfield, hits are
  78.         denoted by the letter 'H'.
  79.  
  80. The rules for how balls deflect rays are simple and are best shown by
  81. example.
  82.  
  83. As a ray approaches a ball it is deflected ninety degrees.  Rays can
  84. be deflected multiple times.  In the diagrams below, the dashes
  85. represent empty box locations and the letter 'O' represents a ball.
  86. The entrance and exit points of each ray are marked with numbers as
  87. described under 'Detour' above.  Note that the entrance and exit
  88. points are always interchangeable.  '*' denotes the path taken by the
  89. ray.
  90.  
  91. Note carefully the relative positions of the ball and the ninety
  92. degree deflection it causes.
  93.  
  94.     1                                            
  95.   - * - - - - - -         - - - - - - - -         - - - - - - - -       
  96.   - * - - - - - -         - - - - - - - -         - - - - - - - -       
  97. 1 * * - - - - - -         - - - - - - - -         - O - - - - O -       
  98.   - - O - - - - -         - - O - - - - -         - - * * * * - -
  99.   - - - - - - - -         - - - * * * * * 2     3 * * * - - * - -
  100.   - - - - - - - -         - - - * - - - -         - - - O - * - -      
  101.   - - - - - - - -         - - - * - - - -         - - - - * * - -       
  102.   - - - - - - - -         - - - * - - - -         - - - - * - O -       
  103.                                 2                         3
  104.  
  105. As mentioned above, a reflection occurs when a ray emerges from the same point
  106. it was sent in.  This can happen in several ways:
  107.  
  108.                                                                            
  109.   - - - - - - - -         - - - - - - - -          - - - - - - - -
  110.   - - - - O - - -         - - O - O - - -          - - - - - - - -
  111. R * * * * - - - -         - - - * - - - -          O - - - - - - -
  112.   - - - - O - - -         - - - * - - - -        R - - - - - - - -
  113.   - - - - - - - -         - - - * - - - -          - - - - - - - -
  114.   - - - - - - - -         - - - * - - - -          - - - - - - - -
  115.   - - - - - - - -       R * * * * - - - -          - - - - - - - -
  116.   - - - - - - - -         - - - - O - - -          - - - - - - - -
  117.  
  118. In the first example, the ray is deflected downwards by the upper ball,
  119. then left by the lower ball, and finally retraces its path to its point
  120. of origin.  The second example is similar.  The third example is a bit
  121. anomalous but can be rationalized by realizing the ray never gets a chance
  122. to get into the box.  Alternatively, the ray can be thought of as being
  123. deflected downwards and immediately emerging from the box.
  124.  
  125. A hit occurs when a ray runs straight into a ball:
  126.  
  127.   - - - - - - - -         - - - - - - - -          - - - - - - - -
  128.   - - - - - - - -         - - - - - - - -          - - - - O - - -
  129.   - - - - - - - -         - - - - O - - -        H * * * * - - - -
  130.   - - - - - - - -       H * * * * O - - -          - - - * - - - -
  131.   - - - - - - - -         - - - - O - - -          - - - O - - - -
  132. H * * * O - - - -         - - - - - - - -          - - - - - - - -
  133.   - - - - - - - -         - - - - - - - -          - - - - - - - -
  134.   - - - - - - - -         - - - - - - - -          - - - - - - - -
  135.  
  136. Be sure to compare the second example of a hit with the first example of
  137. a reflection." "P"])
  138. (byte-code "└┴Mê┬├Mê─┼Mê╞╟Mê╚╔Mê╩╦Mê╠═Mê╬╧Mê╨╤Mê╥╙Mê╘╒Mê╓╫Mç" [bb-init-board #[(num-balls) "└┴!ê┬ëSë╞Y½ö└╟!└╟!B╚ \"¼r B¬d *ç" [random t nil pos board num-balls 0 8 bb-member] 3] bb-insert-board #[nil "└ë├ ê─cê┼\nSë╞Y½à╟cê¬s─c*ç" [nil buffer-read-only i erase-buffer "                     \n" 8 0 "   - - - - - - - -   \n"] 2] bb-right #[nil "┴U?¡ç┬uêTëç" [bb-x 8 2] 2 nil nil] bb-left #[nil "┴U?¡ê┬├!êSëç" [bb-x -1 backward-char 2] 2 nil nil] bb-up #[nil "┴U?¡ê┬├!êSëç" [bb-y -1 previous-line 1] 2 nil nil] bb-down #[nil "┴U?¡ê┬├!êTëç" [bb-y 8 next-line 1] 2 nil nil] bb-eol #[nil "└┬     B!ç" [8 bb-x bb-goto bb-y] 3 nil nil] bb-bol #[nil "└┬     B!ç" [-1 bb-x bb-goto bb-y] 3 nil nil] bb-romp #[nil "┴U¼à┬U½è ┴U«ö ┬U«Å─ \"½à┼ \"ç╞ \"ç" [bb-x -1 8 bb-y bb-outside-box bb-trace-ray bb-place-ball] 3 nil nil] bb-place-ball #[(x y) "    B├\n \"½è┼\n \"╞╟!¬ç\n B╞╚!)ç" [x y coord bb-member bb-balls-placed bb-delete bb-update-board "-" "O"] 3] bb-trace-ray #[(x y) "└┴\në├U½â─¬ë\n┼U½â├¬ü╞ë├U½â─¬è┼U½â├¬ü╞%ë╔=½î╩╦!ê Të ¬╕\nBܽî╩═!ê Të ¬úT╩╧╨\"!êè╤!ê╩╧╨\"!ê) ╥\\ë )ç" [bb-trace-ray-2 t x -1 1 8 0 y result hit bb-update-board "H" bb-score "R" bb-detour-count format "%d" bb-goto 2] 8] bb-trace-ray-2 #[(first x dx y dy) "¼è┴\n \"½ä\n Bç─\n\\ \\B\"½é╚ç─\n\\\\ \\\\B\"½ï╔╩\n[ [%ç─\n[\\\\ [\\\\B\"½ë╔╩\n %ç╔╩\n\\ \\%ç" [first bb-outside-box x y bb-member dx dy bb-board hit bb-trace-ray-2 nil] 6]] 2)
  139. (fset 'bb-done #[nil "└\nG GU¼¥─┼ G╞U½â╟¬ü╚ G G╞U½â╔¬ü╩\nG%¬⌐╦\n \"ë╠U½ê─═\"ê¬ö─╧    ë╞U½â╔¬ü╩    ╨_\\$ê╤╥!)ç" [nil bogus-balls bb-balls-placed bb-board message "There %s %d hidden ball%s; you have placed %d." 1 "is" "are" "" "s" bb-show-bogus-balls 0 "Right!  Your score is %d." bb-score "Oops!  You missed %d ball%s.  Your score is %d." 5 bb-goto (-1 . -1)] 8 "\
  140. Finish the game and report score." nil])
  141. (byte-code "└┴Mê┬├Mê─┼Mê╞╟Mê╚╔Mç" [bb-show-bogus-balls #[(balls-placed board) "└    \n├#ê└\n    ─#ç" [bb-show-bogus-balls-2 balls-placed board "x" "o"] 4] bb-show-bogus-balls-2 #[(list-1 list-2 c) "¼é┴ç┬@ \"½ç─A #ç╞@!ê╟!ê─A #Tç" [list-1 0 bb-member list-2 bb-show-bogus-balls-2 c bb-goto bb-update-board] 4] bb-outside-box #[(x y) "┴U«ì┬U«ê ┴U«â ┬Uç" [x -1 8 y] 2] bb-goto #[(pos) "@┴_A┬_├\\\\bç" [pos 2 22 26] 3] bb-update-board #[(c) "└┬ GS!ê─ G!ê cê┬┼!)ç" [nil buffer-read-only backward-char c delete-char 1] 2]] 2)
  142. (fset 'bb-member #[(elt list) "└┴┬├ \"B!ç" [eval or mapcar #[(x) "    Üç" [x elt] 2] list] 5 "\
  143. Returns non-nil if ELT is an element of LIST.  Comparison done with equal."])
  144. (fset 'bb-delete #[(item list) "    @ܽ⠠  Aç    @┬    A\"Bç" [item list bb-delete] 4 "\
  145. Deletes ITEM from LIST and returns a copy."])
  146.